// 翻转对数量
// 测试链接 : https://leetcode.cn/problems/reverse-pairs/
#include<iostream>
#include<vector>
typedef long long int ll;
using namespace std;

class Solution 
{
public:
    int merge(int left,int mid,int right,vector<int>&arr,vector<int>&tem)
    {
        int ret=0;
        //进行统计
        for(int i=left,j=mid+1;i<=mid;i++)
        {
            while(j<=right&&(long long)arr[j]>2*(long long)arr[i]) j++;
            ret+=j-mid-1;
        }
        int index=left;
        int begin1=left,end1=mid;
        int begin2=mid+1,end2=right;
        while(begin1<=end1&&begin2<=end2) 
        tem[index++]=arr[begin1]<=arr[begin2]?arr[begin1++]:arr[begin2++];
        while(begin1<=end1) tem[index++]=arr[begin1++];
        while(begin2<=end2)tem[index++]=arr[begin2++];
        for(int k=left;k<=right;k++) arr[k]=tem[k];
        return ret;
    }
    int solve(int left,int right,vector<int>&arr,vector<int>&tem)
    {
        if(left>=right) return 0;
        int mid=left+(right-left)/2;
        return solve(left,mid,arr,tem)+solve(mid+1,right,arr,tem)+
        merge(left,mid,right,arr,tem);
    }
    int reversePairs(vector<int>& nums) 
    {
        int n=nums.size();
        vector<int>tem(n);
        return solve(0,n-1,nums,tem);
    }
};
int main()
{
    int n;
    cin>>n;
    vector<int>arr(n);
    for(auto&ch:arr)cin>>ch;
    cout<<Solution().reversePairs(arr)<<endl;
    //for(auto&ch:arr) cout<<ch<< " ";
    return 0;
}